package com.java.pertar.mybatis;

import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TetsSql {



    @Select("select * from user_info")
    List<UserInfo> selectAll();

//    @Select("select * from user_info")
//    Integer selectAll1();

    @Select("select * from user_info where id = #{id}")
    UserInfo selectById(Integer id);


    @Select("select * from user_info where id = #{aa}")
    UserInfo selectById2(Integer id);

    @Select("select * from user_info where username = #{name} and password = #{password}")
    List<UserInfo> select1(String name, String password);

    @Select("select * from user_info where username = #{Name} and password = #{passwrod}")
    UserInfo select2(@Param("Name") String name, @Param("passwrod") String password);

    @Insert("insert into user_info(username, password, age, gender) values (#{name}, #{password}, #{age}, #{gender})")
    void insert(String name, String password, Integer age, Integer gender);

    @Insert("insert into user_info(username, password, age) values (#{name}, #{password}, #{age})")
    void insert2(String name, String password, Integer age);

    @Insert("insert into user_info(username, password, age) values (#{name}, #{password}, #{age})")
    Integer insert3(String name, String password, Integer age);

    @Insert("insert into user_info(username, password, age) values(#{userInfo.username}, #{userInfo.password}, #{userInfo.age})")
    Integer insert4(@Param("userInfo") UserInfo userInfo);

//    @Options(useGeneratedKeys = true, keyProperty = "id")
//    @Insert("insert into user_info(username, password, age) values (#{name}, #{password}, #{age})")
//    Integer insert5(String name, String password, Integer age);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user_info(username, password, age) values (#{username}, #{password}, #{age})")
    Integer insert5(UserInfo userInfo);

    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into user_info(username, password, age) values (#{user.username}, #{user.password}, #{user.age})")
    Integer insert6(@Param("user") UserInfo userInfo);

    @Delete("delete from user_info where id = #{id}")
    Integer deleteById(Integer id);

    @Update("update user_info set delete_flag = #{deleteFlag}, phone = #{phone} where id = #{id}")
    Integer updateById(UserInfo userInfo);

    @Update("update user_info set username = #{username}, age = #{age} where id = #{id}")
    Integer update1(UserInfo userInfo);
}
